<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:p="http://primefaces.prime.com.tr/ui">
<h:head>

</h:head>

<h:body>
	<ui:composition template="/template/common/commonLayout.xhtml">
		<ui:define name="content">
			<h:outputStylesheet library="css" name="settings.css" />
			<h:outputStylesheet library="css" name="table-style.css" />

			<h1 style="color: #709FB3;">#{translatorService.translate('settings.header')}</h1>
			<div id="settings" class="settings">
				<h:form id="dataTableForm">
					<p:messages id="messages" />
					<table class="formTable maxWidth">
						<tr class="formRow1">
							<td class="labelCell doctor">
								<h:outputText value="#{translatorService.translate('settings.doctor')}" />
							</td>
							<td class="inputCell doctor">
								<h:selectOneMenu id="doctors" styleClass="fieldSelection" value="#{settingsController.selectedDoctor}" required="true">
									<f:selectItems
										value="#{settingsController.getDiscreteValueProvider().getDiscreteValueSet('Doctors')}" />
								</h:selectOneMenu>
							</td>
							<td class="labelCell typeOfWork">
								<h:outputText value="#{translatorService.translate('settings.typeOfWork')}" />
							</td>
							<td class="inputCell typeOfWork">
								<h:selectOneMenu styleClass="fieldSelection" value="#{settingsController.selectedWork}">
									<f:selectItems
										value="#{settingsController.getDiscreteValueProvider().getDiscreteValueSet('Ambulances')}" />
								</h:selectOneMenu>
							</td>
							<td class="labelCell dayInWeek">
								<h:outputText value="#{translatorService.translate('settings.dayInWeek')}" />
							</td>
							<td class="inputCell dayInWeek">
								<h:selectOneMenu styleClass="fieldSelection" value="#{settingsController.selectedDay}">
									<f:selectItems
										value="#{settingsController.getDiscreteValueProvider().getDiscreteValueSet('Days')}" />
								</h:selectOneMenu>
							</td>
							<td class="labelCell weekInMonth">
								
							</td>
							<td class="inputCell weekInMonth">
								
							</td>
						</tr>
						<tr class="formRow1">
							<td class="labelCell">
								<h:outputText value="Prvi teden" />
							</td>
							<td>
								<h:selectBooleanCheckbox value="#{settingsController.firstWeek}" />
							</td>
							<td class="labelCell">
								<h:outputText value="Drugi teden" />
							</td>
							<td>
								<h:selectBooleanCheckbox value="#{settingsController.secondWeek}" />
							</td>
							<td class="labelCell">
								<h:outputText value="Tretji teden" />
							</td>
							<td>
								<h:selectBooleanCheckbox value="#{settingsController.thirdWeek}" />
							</td>
							<td class="labelCell">
								<h:outputText value="Četrti teden" />
							</td>
							<td>
								<h:selectBooleanCheckbox value="#{settingsController.fourthWeek}" />
							</td>
						</tr>
					</table>
					<p:spacer width="100%" height="20" />
					<div>
						<p:dataTable id="settingsDatatable"
							value="#{settingsController.settings}" var="setting"
							paginator="true"
							rows="10"
							>
							<p:column sortBy="#{settingsController.getDiscreteValueProvider().getDiscreteValue('Doctors', setting.doctorId)}">
								<f:facet name="header">
									<h:outputLabel value="#{translatorService.translate('settings.doctor')}" />
								</f:facet>
								<h:outputText
									value="#{settingsController.getDiscreteValueProvider().getDiscreteValue('Doctors', setting.doctorId)}" />
							</p:column>
							<p:column sortBy="#{setting.typeOfWork}">
								<f:facet name="header">
									<h:outputLabel value="#{translatorService.translate('settings.typeOfWork')}" />
								</f:facet>
								<h:outputText value="#{settingsController.getTypeOfWorkDescription(setting.typeOfWork)}" />
							</p:column>
							<p:column sortBy="#{setting.dayInWeek}">
								<f:facet name="header">
									<h:outputLabel value="#{translatorService.translate('settings.dayInWeek')}" />
								</f:facet>
								<h:outputText value="#{settingsController.getDayDescription(setting.dayInWeek)}" />
							</p:column>
							<p:column sortBy="#{setting.weekInMonth}">
								<f:facet name="header">
									<h:outputLabel value="#{translatorService.translate('settings.weekInMonth')}" />
								</f:facet>
							    #{setting.weekInMonth}
							</p:column>
							<p:column>
								<p:commandLink
									actionListener="#{settingsController.removeSetting(setting)}"
									value="Odstrani"
									update="dataTableForm:settingsDatatable" />
							</p:column>
						</p:dataTable>
					</div>
					<p:spacer width="100%" height="10"/>
					<p:commandButton value="Dodaj"
						actionListener="#{settingsController.addSetting()}" 
						update="settingsDatatable messages"/>
				</h:form>

			</div>
		</ui:define>
	</ui:composition>
</h:body>

</html>
